<?php

namespace app\common\model;

use app\admin\controller\mall\GoodsSku;
use app\common\lib\Time;
use think\Exception;

class PrinterOrder extends Base
{
    protected $deleteTime = 'delete_time';

    /**
     * @param array $data
     * @return bool
     * @throws Exception
     */
    public function getPrinterByOrderId(array $data = [])
    {
        //查询
        try {
            $row = $this->where('order_id', $data['origin_id'])
                ->find();
        }catch (\Exception $e){
            throw new Exception("操作失败");
        }
        if (!$row) {
            throw new Exception("内部异常");
        }
        $order = $row->toArray();
        $update_data = [
            "update_time"=>time(),
            "print_time"=>$data['print_time']
        ];
        if($data['state'] == 1){
            $update_data['status']=4;
        }else{
            $update_data['status'] = 3;
        }
        $res = $this->updateDataSave($order['id'],$update_data);
        if($res){
            return true;
        }else{
            return false;
        }

    }
}